<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="extUserSearchPackingSlip.do"/>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,java.util.Calendar"%>
<%@ page import="com.scalar.chiptrack.users.Functionality" %>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%@ page import="com.scalar.chiptrack.users.User" %>
<%@ page import="com.scalar.chiptrack.commons.SessionKeys" %>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% User _user1 = (User) session.getAttribute(SessionKeys.USER_KEY); %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>

<SCRIPT language="JavaScript">
var defaultYear;
<%
	Calendar cl   = Calendar.getInstance(); 
%>
	defaultYear = <%=cl.get( Calendar.YEAR )%>

function searchPackingSlips()
{
	document.searchPackingSlipForm.salesOrderNumber.value	= document.searchPackingSlipForm.salesOrderNumber.value.trim();
	document.searchPackingSlipForm.customerPo.value			= document.searchPackingSlipForm.customerPo.value.trim();
	document.searchPackingSlipForm.year.value				= document.searchPackingSlipForm.year.value.trim();

    var salesOrderNo = document.searchPackingSlipForm.salesOrderNumber.value;
    var customerPoNo = document.searchPackingSlipForm.customerPo.value;

    document.getElementById("errors").innerHTML  = "";
    document.getElementById("svrErrors").innerHTML  = "";

    if( salesOrderNo != '')
    {
        if( chkSalesOrderNoBegin ( salesOrderNo ) )
        {
            document.searchPackingSlipForm.salesOrderNumber.focus();
            document.getElementById("errors").innerHTML  = "<br><li>  Sales Order No should not start with special characters ";
            return false;
        }
        if( chkSalesOrderNo ( salesOrderNo ) == false )
        {
            document.searchPackingSlipForm.salesOrderNumber.focus();
            document.getElementById("errors").innerHTML  = "<br><li>  Please enter Valid Sales Order No";
            return false;
        }
    }
    if( customerPoNo != '')
    {
        if( chkSalesOrderNoBegin ( customerPoNo ) )
        {
            document.searchPackingSlipForm.customerPo.focus();
            document.getElementById("errors").innerHTML  = "<br><li>  Customer PO No should not start with special characters ";
            return false;
        }
        if( chkSalesOrderNo ( customerPoNo ) == false )
        {
            document.searchPackingSlipForm.customerPo.focus();
            document.getElementById("errors").innerHTML  = "<br><li>  Please enter Valid Customer PO No";
            return false;
        }
    }
    document.searchPackingSlipForm.action					= "<%=chipTracContext%>/extUserSearchPackingSlip.do?action=Search";	

    return true;
}

    function submitPage()
    {
        if ( searchPackingSlips() )
        {
            document.searchPackingSlipForm.submit();        
        }
    }

    function generatePackingSlip( salesOrderId, locationId )
    {
        document.searchPackingSlipForm.action = "<%=chipTracContext%>/vendorPackingSlip.do?action=loadSalesOrder&salesOrderId=" + salesOrderId+"&dropShip=true&vendorLocationId="+locationId;
        document.searchPackingSlipForm.submit();
    }

    function searchOpenPackingSlips()
    {
        if ( searchPackingSlips() )
        {
            document.searchPackingSlipForm.salesOrderNumber.value	= document.searchPackingSlipForm.salesOrderNumber.value.trim();
            document.searchPackingSlipForm.customerPo.value			= document.searchPackingSlipForm.customerPo.value.trim();
            document.searchPackingSlipForm.year.value				= document.searchPackingSlipForm.year.value.trim();
            document.searchPackingSlipForm.sePsStatus.value			= 'OPEN';
            document.searchPackingSlipForm.year.value				= defaultYear;
            //document.searchPackingSlipForm.action					= "<%=chipTracContext%>/searchPackingSlip.do?action=Search";
            document.searchPackingSlipForm.submit();
        }
    }

</SCRIPT>

<!-- Top Header Start-->

<%@ include file="/jsp/includes/extHeader.jsp" %>

<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
	<TBODY>
	<TR>
		<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
		<%@ include file="/jsp/admin/externaluser_menu.jsp" %>
<!-- end of the side navigations -->
		</td>
		<td bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=10></td>
		<td valign="top" width="100%">
			<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0><BR>

<!-- from here your body starts -->

			<html:form name="searchPackingSlipForm" method="post" action="/extUserSearchPackingSlip" type="com.scalar.chiptrack.operations.packingslip.forms.SearchPackingSlipForm" >
			<center><span class="NArialW">Packing Slip</span></center>
			<table border="0" width="100%" align=right >
                <%
                    if ( _user1 != null && !_user1.isActionAllowed ( Functionality.PACKING_SLIP, User.USER_ACTION_VIEW  )  )
                    {
                %>
                <tr><td><font class="NArialS"><font color="blue"><b>You don't have permission to view Packing Slip(s)</b></font><td><tr>
                <%
                    }
                %>

                <tr>
					<td>
						<table border="0" width="100%" align=right>
						<tr><td colspan=5 class="NArialL" align="left"><font color="FF0000"><FONT id="errors"></FONT></font></td></tr>
						<tr><td colspan=5 id="svrErrors"><chiptrack:errors styleClass="NArialL"/></td></tr>
						<tr><td colspan=5 id="svrInfo"><chiptrack:info styleClass="NArialL"/></td></tr>
						<tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
						<tr>
							<td width="25%"><font class="NArialL">Sales Order #</font></td>
							<td width="20%"><font class="NArialL">
								<html:text name="searchPackingSlipForm" property="salesOrderNumber" styleClass="txfield"/>
							</td>
							<td width="5%">&nbsp;</td>
							<td width="25%" class="NArialL">Customer PO # </td>
							<td width="20%">
								<html:text name="searchPackingSlipForm" property="customerPo" styleClass="txfield"/>     	
							</td>
						</tr>
						<tr>
						    <td width="25%"><font class="NArialL">Packing Slip Status </font></td>
							<td width="20%"><font class="NArialL">
								<html:select name="searchPackingSlipForm" property="sePsStatus" styleClass="txfield">
									<html:option value="0">All</html:option>
                                    <html:option value="OPEN">OPEN</html:option>
                                    <html:option value="ISSUED"> ISSUED </html:option>
									<html:option value="SHIPPED"> SHIPPED </html:option>
									<html:option value="CANCELLED"> CANCELLED </html:option>
								</html:select>
                            </td>
							<td width="5%">&nbsp;</td>
							<td width="15%"><font class="NArialL"> Year</font></td>
							<td width="25%"><font class="NArialL">
                                <html:select name="searchPackingSlipForm"  property="year" styleClass="txfield">
                                    <html:option value="0">--All--</html:option>
                                    <html:options collection="yearList" property="value" labelProperty="label" />
                                </html:select>
							</font></td>
						</tr>
                        <tr>
							<td width="25%" class="NArialL">Category</td>
							<td width="20%">
                                <html:select name="searchPackingSlipForm" property="orderType" styleClass="txfield">
                                    <html:option value="1">Regular</html:option>
                                    <html:option value="0">Sample</html:option>
                                </html:select>
                            </td>
							<td width="5%">&nbsp;</td>
							<td colspan="2"><font class="NArialL"><html:checkbox name="searchPackingSlipForm" property="lineItemWise" styleClass="txfield"/>&nbsp;Display Line Item Wise</font></td>
						</tr>
						<tr><td colspan='5'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
						<tr>
							<td colspan="5" align="center">
                                <chiptrack:restrictedLink href="javascript:submitPage();" functionality="<%=Functionality.PACKING_SLIP%>">
                                    <img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click to Search for Packing Slip';return true" onmouseout="window.status='';return true" title="Click here to Search for Packing Slip">
                                </chiptrack:restrictedLink>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<a href="javascript:document.searchPackingSlipForm.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
							</td>
						</tr>
                        <tr><td colspan="5" align=left  class="NArialL">Click here to <a href="javascript:searchOpenPackingSlips();"onmouseover="window.status='Click to Generate New Packing Slip';return true" onmouseout="window.status='';return true"><bean:message key="label.packingSlip.Generate"/></a> Packing slip </td> </tr>
                        </table>
					</td>
				</tr>
				<tr><td><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr>
				<tr>
					<td>
						<logic:present name="searchList">
						<table border="0" width="100%" bordercolor="#FFFFFF" align=right>
							<tr>          
								<td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Sales Order #</font></td>
								<td width="20%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Customer Name</font></td>
								<td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Customer PO #</font></td>
                                <logic:equal name="searchPackingSlipForm" property="lineItemWise" value="true">
                                    <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Line Item #</font></td>
                                    <% if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MFG_PARTNO_PACKINGSLIP ) ) { %>
                                    <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"><bean:message key="label.mfgPartNumber"/></font></td>

                                    <% } %>
                                      <% if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MRKT_PARTNO_PACKINGSLIP ) ) { %>
                                    <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"><bean:message key="label.mktgPartNumber"/></font></td>
                                    <% } %>
                                    <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Remaining Qty</font></td>
                                </logic:equal>
                                <td width="7%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Latest Sch. Date</font></td>
                                <td width="7%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Invoice #</font></td>
								<td width="13%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Packing Slip #</font></td>
								<td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Location </font></td>
								<td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"> Type </font></td>
								<td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Status</font></td>
								<td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Actions</font></td>
							</tr>
						<tr>
							<td colspan=5><chiptrack:messages type="error" styleClass="NArialL" /></td>
						</tr>
						<logic:iterate id="PackingSlip" name="searchList" indexId="iteratorIdx">
						<tr <%if(iteratorIdx.intValue()%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>>
							<td width="10%" ><font class="NArialL"><bean:write name="PackingSlip" property="salesOrderNo"/></font></td>
							<td width="20%" ><font class="NArialL"><bean:write name="PackingSlip" property="customerName"/></font></td>
							<td width="10%" ><font class="NArialL"><bean:write name="PackingSlip" property="customerPoNo"/></font></td>
                            <logic:equal name="searchPackingSlipForm" property="lineItemWise" value="true">
                                <td width="10%" align="middle" ><font class="NArialL"><bean:write name="PackingSlip" property="lineItemNo"/></font></td>
                                <% if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MFG_PARTNO_PACKINGSLIP ) ) { %>
                                <td width="10%" nowrap ><font class="NArialL"><bean:write name="PackingSlip" property="partNumber"/></font></td>
                                <% } %>
                                 <%      if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MRKT_PARTNO_PACKINGSLIP ) ) { %>
                                <td width="10%" nowrap ><font class="NArialL"><bean:write name="PackingSlip" property="mrktPartNumber"/></font></td>
                                <% } %>
                                <td width="10%" align="middle" ><font class="NArialL"><bean:write name="PackingSlip" property="remainingQty"/></font></td>
                            </logic:equal>
                            <td width="7%" ><font class="NArialL"><bean:write name="PackingSlip" property="maxScheduleDate"/></font></td>
                            <td width="7%" ><font class="NArialL"><bean:write name="PackingSlip" property="invNo"/></font></td>
							<td width="13%" align="left" ><font class="NArialL">
								<logic:notEqual name="PackingSlip" property="label" value="null">
									<bean:write name="PackingSlip" property="label"/>
								</logic:notEqual></font></td>          
							<td width="10%" align="left"><font class="NArialL">
								<logic:notEqual name="PackingSlip" property="location" value="null">
									<bean:write name="PackingSlip" property="location"/>
									<html:hidden name="PackingSlip" property="location"/>
								</logic:notEqual>
								</font></td>          
							<td width="10%" align="left"><font class="NArialL">
								<logic:equal name="PackingSlip" property="isDropShipment" value="0">
									<bean:message key="label.packingSlip.DropShip"/>
								</logic:equal>	
								<logic:equal name="PackingSlip" property="isDropShipment" value="1">
									Packing Slip
								</logic:equal></font></td>
							<td width="10%" ><font class="NArialL"><bean:write name="PackingSlip" property="status"/></font></td>
							<td width="10%"><font class="NArialL">
								<logic:equal name="PackingSlip" property="status" value="SHIPPED">
									<A Href='<%=chipTracContext%>/shippingAdvise.do?ps=<bean:write name="PackingSlip" property="customerShippingId"/>&cstKey=0' onmouseover="window.status='Click to View/Update Packing Slip';return true" onmouseout="window.status='';return true">View/Update</A>
								</logic:equal>
								<logic:equal name="PackingSlip" property="status" value="CANCELLED">
									<A Href='<%=chipTracContext%>/shippingAdvise.do?ps=<bean:write name="PackingSlip" property="customerShippingId"/>&cstKey=0'onmouseover="window.status='Click to View Packing Slip';return true" onmouseout="window.status='';return true">View</A>
								</logic:equal>
								<logic:equal name="PackingSlip" property="status" value="ISSUED">
									<A Href='<%=chipTracContext%>/shippingAdvise.do?ps=<bean:write name="PackingSlip" property="customerShippingId"/>&cstKey=0' onmouseover="window.status='Click to View/Modify Packing Slip';return true" onmouseout="window.status='';return true">View/Modify</A>
								</logic:equal>
                                <logic:equal name="PackingSlip" property="status" value="OPEN">
									<A Href='javascript:generatePackingSlip(<bean:write name="PackingSlip" property="salesOrderId"/>,<bean:write name="PackingSlip" property="locationAddressId"/>)' onmouseover="window.status='Click to Generate Packing Slip';return true" onmouseout="window.status='';return true">Generate</A>
								</logic:equal>
                            </td>
						</tr>
						</logic:iterate>
						</table>
						</logic:present>
					</td>
				</tr>
			</table>
			</html:form>
<!-- body ends here -->
		</td>
	</tr>
	</tbody>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>

<!-- footer end here -->

</BODY>
</HTML>